/**   
* @Title: Result.java
* @Package org.xaoyaoyao.cloud.job.result
* @Description: TODO
* @author xaoyaoyao
* @date 2018年9月7日 下午1:33:32
* @version V1.0   
*/
package org.xaoyaoyao.cloud.job.result;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName: Result
 * @Description: TODO
 * @author xaoyaoyao
 * @date 2018年9月7日 下午1:33:32
 * 
 */
public class Result extends HashMap<String, Object> {

	private static final long serialVersionUID = 4338704801791363393L;

	public Result() {
		put("code", 0);
	}

	public static Result error() {
		return error(500, "未知异常，请联系管理员");
	}

	public static Result error(String msg) {
		return error(500, msg);
	}

	public static Result error(int code, String msg) {
		Result r = new Result();
		r.put("code", code);
		r.put("msg", msg);
		return r;
	}

	public static Result ok(Object msg) {
		Result r = new Result();
		r.put("msg", msg);
		return r;
	}

	public static Result ok(Map<String, Object> map) {
		Result r = new Result();
		r.putAll(map);
		return r;
	}

	public static Result ok() {
		return new Result();
	}

	@Override
	public Result put(String key, Object value) {
		super.put(key, value);
		return this;
	}

}